<!DOCTYPE html>
<html lang="en"><head>
<title>HTML Imports</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" href="spec.css" type="text/css">
<link rel="stylesheet" href="prettify.css" type="text/css">
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-WD" type="text/css">
</head>

<body>

<div class="head">

<div class="logo">
    <a href="http://www.w3.org/"><img width="72" height="48" src="http://www.w3.org/Icons/w3c_home" alt="W3C"></a>
</div>

<h1>HTML Imports</h1>
<h2 id="editors-draft">W3C First Public Working Draft 14 May 2013</h2>
<dl>
<dt>This version</dt>
    <dd><a href="http://www.w3.org/TR/2013/WD-html-imports-20130514/">http://www.w3.org/TR/2013/WD-html-imports-20130514/</a></dd>
<dt>Latest version</dt>
    <dd><a href="http://www.w3.org/TR/html-imports/">http://www.w3.org/TR/html-imports/</a></dd>
<dt>Latest editor's draft</dt>
    <dd><a href="https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html">https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html</a></dd>
<dt>Previous version</dt>
    <dd>none</dd>
<dt>Revision history</dt>
    <dd><a id="log" href="https://dvcs.w3.org/hg/webcomponents/log/tip/spec/imports/index.html">https://dvcs.w3.org/hg/webcomponents/log/tip/spec/imports/index.html</a></dd>
<dt>Participate</dt>
    <dd>Discuss on <a href="http://lists.w3.org/Archives/Public/public-webapps/">public-webapps@w3.org</a> (<a href="http://www.w3.org/2008/webapps/">Web Applications Working Group</a>)</dd>
    <dd><a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?comment=&amp;blocked=20683&amp;short_desc=%5Bimports%5D%3A%20&amp;product=WebAppsWG&amp;import=import%20Model">File bugs</a> (w3.org's <a href="https://www.w3.org/Bugs/Public/">Bugzilla</a>)</dd>
<dt>Editor</dt>
    <dd class="vcard"><span class="fn">Dimitri Glazkov</span>, <span class="org">Google</span>, &lt;<a class="email" href="mailto:dglazkov@chromium.org">dglazkov@chromium.org</a>&gt;</dd>
</dl>

<p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2013 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p>

<hr>

<h2 id="abstract">Abstract</h2>

<p>HTML Imports are a way to include and reuse HTML documents in other HTML documents.</p>

<h2 id="status">Status of This Document</h2>

<p><em>This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the <a href="http://www.w3.org/TR/">W3C technical reports index</a> at http://www.w3.org/TR/.</em></p>

<p>Publication as a First Public Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.</p>

<p>This document was published by the <a href="http://www.w3.org/2008/webapps/">Web Applications Working Group</a> as an Editor's Draft. If you wish to make comments regarding this document, please send them to <a href="mailto:public-webapps@w3.org">public-webapps@w3.org</a> (<a href="mailto:public-webapps-request@w3.org?subject=subscribe">subscribe</a>, <a href="http://lists.w3.org/Archives/Public/public-webapps/">archives</a>). All feedback is welcome.</p><p>Publication as an Editor's Draft does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr> Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.</p>

<p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>. <abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="http://www.w3.org/2004/01/pp-impl/42538/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.</p>

</div>

<section class="toc">
<h2 id="toc">Table of Contents</h2>
<ol>
    <li><a href="#about"><span class="section">1</span> About this Document</a></li>
    <li><a href="#dependencies"><span class="section">2</span> Dependencies</a></li>
    <li><a href="#terminology"><span class="section">3</span> Terminology</a></li>
    <li><a href="#link-type-import"><span class="section">4</span> Link Type "<code>import</code>"</a></li>
    <li><a href="#interface-import"><span class="section">5</span> Interface <code>import</code></a></li>
    <li><a href="#loading-imports"><span class="section">6</span> Loading Imports</a></li>
    <li><a href="#parsing-imports"><span class="section">7</span> Parsing Imports</a>
    <ol>
        <li><a href="#additions-to-prepare-a-script-algorithm"><span class="section">7.1</span> Additions to Prepare A Script Algorithm</a></li>
        <li><a href="#additions-to-tree-construction-algorithm"><span class="section">7.2</span> Additions to Tree Construction Algorithm</a></li>
        <li><a href="#additions-to-parsing-xhtml-documents"><span class="section">7.3</span> Additions to Parsing XHTML Documents</a></li>
    </ol></li>
    <li><a href="#acknowledgements">Acknowledgements</a></li>
</ol>
</section>

<section class="spec">
<h2 id="about">About this Document</h2>

<p>All diagrams, examples, notes, are non-normative, as well as sections explicitly marked as non-normative. Everything else in this specification is normative.</p>

<p>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in <a href="http://dev.w3.org/2006/xbl2/#refsRFC2119">RFC2119</a>. For readability, these words do not appear in all uppercase letters in this specification.</p>

<p>Any point, at which a conforming UA must make decisions about the state or reaction to the state of the conceptual model, is captured as <a href="http://en.wikipedia.org/wiki/Algorithm">algorithm</a>. The algorithms are defined in terms of processing equivalence. The <dfn id="dfn-processing-equivalence">processing equivalence</dfn> is a constraint imposed on the algorithm implementors, requiring the output of the both UA-implemented and the specified algorithm to be exactly the same for all inputs.</p>

<h2 id="dependencies">Dependencies</h2>

<p>This document relies on the following specifications:</p>

<ul>
<!--     <li><a href="http://www.w3.org/TR/CSS2/">CSS Level 2 Revision 1</a></li>
    <li><a href="http://dev.w3.org/csswg/cssom/">CSSOM</a></li>
    <li><a href="http://www.w3.org/TR/DOM-Level-3-Events/">DOM Level 3 Events</a></li> -->
    <li><a href="http://dom.spec.whatwg.org/">DOM4 (DOM Core)</a></li>
    <li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">HTML</a></li>
    <li><a href="http://html5.org/specs/dom-parsing.html">DOM Parsing and Serialization</a></li>
    <li><a href="http://ecma-international.org/ecma-262/5.1/">ECMAScript Language Specification</a></li>
    <li><a href="http://url.spec.whatwg.org/">URL</a></li>
<!--     <li><a href="http://www.w3.org/TR/selectors/">Selectors Level 3</a></li>
    <li><a href="http://dev.w3.org/2006/webapi/selectors-api/">Selectors API Level 1</a></li>
    <li><a href="http://www.w3.org/TR/shadow-dom/">Shadow DOM</a></li>
    <li><a href="http://www.w3.org/TR/WebIDL/">Web IDL</a></li> -->
</ul>

<h2 id="terminology">Terminology</h2>

<p>HTML Imports, or just <dfn id="dfn-import">imports</dfn> from here on, are <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html">HTML documents</a> that are <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element">linked</a> as <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#external-resource-link">external resources</a> from another <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html">HTML document</a>. The document that links to an <a href="#dfn-import">import</a> is called a <dfn id="dfn-master-document">master document</dfn>.</p>

<p>The <a href="http://dom.spec.whatwg.org/#concept-document">document</a> that represents an <a href="#dfn-import">import</a> is called the <dfn id="dfn-imported-document">imported document</dfn>, and the <a href="http://dom.spec.whatwg.org/#concept-document-url">URL</a> of the <a href="#dfn-imported-document">imported document</a> is called the <dfn id="dfn-import-location">import location</dfn>.</p>

<h2 id="link-type-import">Link Type "<code>import</code>"</h2>

<p>To enable declaring <a href="#dfn-import">imports</a> in HTML, a new link type is added to <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#linkTypes">HTML link types</a>:</p>

<div class="monkeypatch">
<p>The <a href="#link-type-import"><code>import</code></a> keyword may be used with <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element"><code>link</code></a> elements. This keyword creates an <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#external-resource-link">external resource link</a> to a <a href="#dfn-import">import</a>.</p>

<p>The default type for resources given by the <a href="#link-type-import"><code>import</code></a> keyword is <code>text/html</code>.</p>

<p>The appropriate time to <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#concept-link-obtain">obtain</a> the resource is when the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#external-resource-link">external resource link</a> is created or when its element is <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#insert-an-element-into-a-document">inserted into a document</a>, whichever happens last.</p>
</div>

<div class="informative">
<p>The following document has one import, located at <kbd>/imports/heart.html</kbd>:</p>

<pre><code class="prettyprint">
&lt;!DOCTYPE html&gt;
&lt;html lang="en-US"&gt;
    &lt;head&gt;
        &lt;title&gt;Human Being&lt;/title&gt;
        &lt;link rel="import" href="/imports/heart.html"&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;p&gt;What is a body without a heart?&lt;/p&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
</div>

<h2 id="interface-import">Interface <code>Import</code></h2>

<p>The <a href="#api-import"><code>Import</code></a> interface represents an <a href="#dfn-import">import</a> in a <a href="#dfn-master-document">master document</a>:</p>

<pre><code>
interface <dfn id="api-import">Import</dfn> {
    readonly attribute DOMString? <a href="#dfn-import-href">href</a>;
    readonly attribute Node <a href="#dfn-import-owner-node">ownerNode</a>;
    readonly attribute <a href="http://dom.spec.whatwg.org/#document">Document</a> <a href="#dfn-import-content">content</a>;
};
</code></pre>

<p>The <dfn id="dfn-import-href"><code>href</code></dfn> attribute <strong>must</strong> return the <a href="#dfn-import-location">import location</a> or <strong>null</strong> if none.</p>

<p>The <dfn id="dfn-import-owner-node"><code>ownerNode</code></dfn> attribute <strong>must</strong> return the <a href="http://dom.spec.whatwg.org/#concept-node">node</a> that links <a href="#dfn-master-document">master document</a> to the <a href="#dfn-import">import</a>.</p>

<p>The <dfn id="dfn-import-content"><code>content</code></dfn> attribute <strong>must</strong> return the <a href="#dfn-imported-document">imported document</a>.</p>

<p>The <a href="#api-link-import"><code>LinkImport</code></a> interface provides access to a <a href="#dfn-import">import</a> from <a href="#dfn-master-document">master document</a>:</p>

<pre><code>
[NoInterfaceObject]
interface <dfn id="api-link-import">LinkImport</dfn> {
    readonly attribute <a href="#api-import">Import?</a> <a href="#dfn-link-import-import">import</a>;
}
</code></pre>

<p>The <dfn id="dfn-link-import-import"><code>import</code></dfn> attribute must return the <a href="#api-import"><code>import</code></a> for the <a href="http://dom.spec.whatwg.org/#concept-node">node</a> that implements this interface.</p>

<div class="monkeypatch" id="html-link-monkeypatch">
<p>The <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element"><code>link</code></a> element implements <a href="#api-link-import"><code>LinkImport</code></a> interface:</p>
<pre><code>
<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#htmllinkelement">HTMLLinkElement</a> implements <a href="#api-link-import">LinkImport</a>;
</code></pre>

<p>For <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element"><code>link</code></a> elements that do not represent <a href="#dfn-import">imports</a>, the <a href="#dfn-link-import-import"><code>import</code></a> attribute of the <a href="#api-link-import"><code>LinkImport</code></a> interface <strong>must</strong> return <strong>null</strong>. Similarly, if the user agent does not support <a href="#dfn-import">imports</a>, or whose resource is <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/fetching-resources.html#cors-cross-origin">CORS-cross-origin</a>, the <a href="#dfn-link-import-import"><code>import</code></a> attribute of the <a href="#api-link-import"><code>LinkImport</code></a> interface <strong>must</strong> return <strong>null</strong>.</p>

<p>Otherwise, the <a href="#api-link-import"><code>LinkImport</code></a> interface's <a href="#dfn-link-import-import"><code>import</code></a> attribute <strong>must</strong> return <strong>null</strong> if the corresponding element is not <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#in-a-document">in a <code>Document</code></a>, and otherwise <strong>must</strong> return a <a href="#api-import"><code>Import</code></a> object with the following properties:</p>

<dl>
<dt>import location</dt>
<dd>The <a href="#dfn-import-location">import location</a> <strong>must</strong> be the result of <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#resolve-a-url">resolving</a> the <a href="http://url.spec.whatwg.org/#concept-url">URL</a> given by <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element"><code>link</code></a> element's <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#attr-link-href"><code>href</code></a> content attribute, relative to the element, or empty string if that fails.
</dd><dt>owner node</dt>
<dd>The owner node value <strong>must</strong> be the the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element"><code>link</code></a> element.</dd>
</dl>

<p>The same object <strong>must</strong> be returned each time.</p>

<p><a href="#dfn-import">imports</a> have an <dfn id="dfn-import-ready-flag">import ready flag</dfn>, which is initially unset. When an import is ready to be used, its <a href="#dfn-import-ready-flag">import ready flag</a> <strong>must</strong> be set.</p>

<p>A <a href="#dfn-import">import</a> in the context of the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document"><code>Document</code></a> of an <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#html-parser">HTML parser</a> or <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#xml-parser">XML Parser</a> is said to be <dfn id="dfn-an-import-that-is-blocking-scripts">an import that is blocking scripts</dfn> if the <a href="http://dom.spec.whatwg.org/#concept-element">element</a> was created by that <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document"><code>Document</code></a>'s parser, and the <a href="http://dom.spec.whatwg.org/#concept-element">element</a> is a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element"><code>link</code></a> of type <a href="#link-type-import"><code>import</code></a> when the <a href="http://dom.spec.whatwg.org/#concept-element">element</a> was created by the parser, and the <a href="http://dom.spec.whatwg.org/#concept-element">element</a>'s <a href="#dfn-import-ready-flag">import ready flag</a> is not yet set, and, the last time the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-loop">event loop</a> has reached step 1, the <a href="http://dom.spec.whatwg.org/#concept-element">element</a> was <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#in-a-document">in that <code>Document</code></a>, and the user agent hasn't given up on that <a href="#dfn-import">import</a> yet. A user agent may give up on a <a href="#dfn-import">import</a> at any time.</p>

</div>
<div class="informative">
<p>
Giving up an import before it loads, even if the import eventually does still load, means that the script might end up operating with incorrect information. For example, if an import registers a custom element and a script relies on the availability of this element, the script will find that this element is unavailable if the user agent gives up early. Implementors have to balance the likelihood of a script using incorrect information with the performance impact of doing nothing while waiting for a slow network request to finish.
</p>
</div>

<div class="monkeypatch">
<p>A <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document"><code>Document</code></a> <dfn id="dfn-has-an-import-that-is-blocking-scripts">has an import that is blocking scripts</dfn> if there is either a <a href="#dfn-an-import-that-is-blocking-scripts">an import that is blocking scripts</a> in the context of that <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document"><code>Document</code></a>, or if that <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document"><code>Document</code></a> is in a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#browsing-context">browsing context</a> that has a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#parent-browsing-context">parent browsing context</a>, and the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#active-document">active document</a> of that <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#parent-browsing-context">parent browsing context</a> itself <a href="#dfn-has-an-import-that-is-blocking-scripts">has an import that is blocking scripts</a>.</p>

<p>A <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document"><code>Document</code></a> <dfn id="dfn-has-no-import-that-is-blocking-scripts">has no import that is blocking scripts</dfn> if it does not <a href="#dfn-has-no-import-that-is-blocking-scripts">have an import that is blocking scripts</a> as defined in the previous paragraph.</p>

</div>

<h2 id="loading-imports">Loading Imports</h2>

<p>The list of all <a href="#dfn-import">imports</a> that have been loaded by the <a href="#dfn-master-document">master document</a> is kept in the <dfn id="dfn-loaded-import-list">loaded import list</dfn>, an ordered list of <a href="#dfn-import-location">import location</a> and <a href="#dfn-imported-document">imported document</a> pairs. New items are added to the bottom of the list.</p>

<p>When a <a href="#dfn-import">import</a> is <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/fetching-resources.html#fetch">fetched</a>, the user agent <strong>must</strong> run the <dfn id="dfn-import-fetching">import fetching</dfn> algorithm, which <strong>must</strong> be <a href="#dfn-processing-equivalence">equivalent</a> to running these steps:</p>
<div class="algorithm">
<dl>
<dt>Input</dt>
<dd><var>LOCATION</var>, the <a href="#dfn-import-location">import location</a></dd>
<dt>Output</dt>
<dd><var>DOCUMENT</var>, the <a href="#dfn-imported-document">imported document</a></dd>
</dl>
<ol>
    <li>If <var>LOCATION</var> is already in the <a href="#dfn-loaded-import-list">loaded import list</a>, let <var>DOCUMENT</var> be the <a href="#dfn-imported-document">imported document</a> for <var>LOCATION</var> and <strong>stop</strong>.</li>
    <li>Let <var>DOCUMENT</var> be a new <a href="http://dom.spec.whatwg.org/#concept-document">Document</a> that is an <a href="http://dom.spec.whatwg.org/#html-document">HTML document</a> with no <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#browsing-context">browsing context</a></li>
    <li>Set <var>DOCUMENT</var>'s <a href="http://dom.spec.whatwg.org/#concept-document-content-type">content type</a> to "<code>text/html</code>".</li>
    <li>Set <var>DOCUMENT</var>'s <a href="http://dom.spec.whatwg.org/#concept-document-url">URL</a> to <var>LOCATION</var></li>
    <li>Let <var>PARSER</var> be a new <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#html-parser">HTML parser</a>, associated with <var>DOCUMENT</var></li>
    <li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/fetching-resources.html#fetch">Fetch a resource</a> from <var>LOCATION</var>, with <var>DOCUMENT</var> as <em>override referrer source</em> and <em>block cookies</em> flag set:
    <ol>
        <li>For each <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-task">task</a> that the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-task">networking task source</a> places on the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#task-queue">task queue</a> while fetching:
        <ol>
            <li>Fill <var>PARSER</var>'s <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#the-input-byte-stream">input byte stream</a> with the fetched bytes</li>
            <li>Let <var>PARSER</var> process the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#the-input-byte-stream">input byte stream</a></li>
        </ol></li>
        <li>When no more bytes are available:
        <ol>
            <li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#queue-a-task">Queue a task</a> from the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#networking-task-source">networking task source</a> for <var>PARSER</var> to process implied <code>EOF</code> character</li>
            <li>Add <var>LOCATION</var> and <var>DOCUMENT</var> to the <a href="#dfn-loaded-import-list">loaded import list</a></li>
            <li><a href="#dfn-sub-import-processing">Process sub-imports</a>.</li>
    </ol></li>
</ol>
</li></ol></div>

<p>Each loaded <a href="#dfn-import">import</a> may also contain <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element">links</a> to other <a href="#dfn-import">imports</a>, called <dfn id="dfn-sub-import">sub-imports</dfn>.</p>

<p>The <a href="#dfn-sub-import">sub-imports</a> are discovered and processed with the <dfn id="dfn-sub-import-processing">sub-import processing</dfn> algorithm, which <strong>must</strong> be <a href="#dfn-processing-equivalence">equivalent</a> to these steps:</p>
<div class="algorithm">
<dl>
<dt>Input</dt>
<dd><var>DOCUMENT</var> the <a href="#dfn-import">import</a> document</dd>
</dl>
<ol>
    <li>For each <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element"><code>link</code></a> element in the <a href="#dfn-import">import</a>'s <a href="http://dom.spec.whatwg.org/#concept-document">document</a>, in <a href="http://dom.spec.whatwg.org/#concept-tree-order">tree order</a>:
    <ol>
        <li>Let <var>LINK</var> be this <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element"><code>link</code></a> element</li>
        <li>If <var>LINK</var>'s <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#linkTypes">type</a> is <a href="#link-type-import"><code>import</code></a>:
        <ol>
            <li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#concept-link-obtain">Obtain</a> the <a href="#dfn-import">import</a> resources using <var>LINK</var> and <a href="#dfn-import-fetching">import fetching</a> algorithm</li>
        </ol></li>
    </ol></li>
</ol>
</div>

<h2 id="parsing-imports">Parsing Imports</h2>

<p>The parsing of <a href="#dfn-import">imports</a> is defined as a set of changes to the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#parsing">HTML Parsing</a>.</p>

<h3 id="additions-to-prepare-a-script-algorithm">Additions to Prepare A Script Algorithm</h3>

<p>In step 15 of <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#prepare-a-script">prepare a script</a> algorithm, modify the last part of condition which begins with <em>If element does not have a <code>src</code> attribute</em> to read:</p>
<div class="monkeypatch">
<p>... and the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document"><code>Document</code> of the </a><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#html-parser">HTML parser</a> or <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#xml-parser">XML parser</a> that created the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element"><code>script</code></a> element <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#has-a-style-sheet-that-is-blocking-scripts">has a style sheet that is blocking scripts</a> or <a href="#dfn-has-an-import-that-is-blocking-scripts">has an import that is blocking scripts</a></p>
</div>

<h3 id="additions-to-tree-construction-algorithm">Additions to Tree Construction Algorithm</h3>

<p>In sub-condition named <em>Otherwise</em> of condition <em>An end tag whose name is "script"</em> in <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#parsing-main-incdata">"text" insertion mode</a>, modify step 3 to read:</p>
<div class="monkeypatch">
<ol start="3">
    <li>If the parser's <code><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document">Document</a></code> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#has-a-style-sheet-that-is-blocking-scripts">has a style sheet that is blocking scripts</a> or <a href="#dfn-has-an-import-that-is-blocking-scripts">has an import that is blocking scripts</a> or <em>the script</em>'s <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is not set: <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#spin-the-event-loop">spin the event loop</a> until the parser's <code><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document">Document</a></code> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#has-no-style-sheet-that-is-blocking-scripts">has no style sheet that is blocking scripts</a> and <a href="#dfn-has-no-import-that-is-blocking-scripts">has no import that is blocking scripts</a> and the script's <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</li>
</ol>
</div>

<p>Modify sub-step 1 of step 3 of <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#the-end">the end</a> to read:</p>
<div class="monkeypatch">
<ol>
    <li><p><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#spin-the-event-loop">Spin the event loop</a> until the first <code><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element">script</a></code> in the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the document has finished parsing</a> has its <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> the parser's <code><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document">Document</a></code> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#has-no-style-sheet-that-is-blocking-scripts">has no style sheet that is blocking scripts</a> <em>and</em> has <a href="#dfn-has-no-import-that-is-blocking-scripts">has no import that is blocking scripts</a>.</p></li>    
</ol>
</div>

<h3 id="additions-to-parsing-xhtml-documents">Additions to Parsing XHTML Documents</h3>

<p>Modify step 3 of steps that run following <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#prepare-a-script">preparing</a> the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element"><code>script</code></a> element to read:</p>
<div class="monkeypatch">
<ol start="3">
    <li><p><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#spin-the-event-loop">Spin the event loop</a> until the parser's <code><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document">Document</a></code> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#has-no-style-sheet-that-is-blocking-scripts">has no style sheet that is blocking scripts</a> and <a href="#dfn-has-no-import-that-is-blocking-scripts">has no import that is blocking scripts</a> and the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#pending-parsing-blocking-script">pending parsing-blocking script</a>'s <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
</ol>
</div>

<h2 id="acknowledgements">Acknowledgements</h2>

<p><span class="vcard">David Hyatt</span> developed <a href="http://dev.w3.org/2006/xbl2/">XBL 1.0</a>, and <span class="vcard">Ian Hickson</span> co-wrote <a href="http://dev.w3.org/2006/xbl2/">XBL 2.0</a>. These documents provided tremendous insight into the problem of behavior attachment and greatly influenced this specification.</p>

<p><span class="vcard">Alex Russell</span> and his considerable forethought triggered a new wave of enthusiasm around the subject of behavior attachment and how it can be applied practically on the Web.</p>

<p><span class="vcard">Dominic Cooney</span>, <span class="vcard">Hajime Morrita</span>, and <span class="vcard">Roland Steiner</span> worked tirelessly to scope the problem within the confines of the Web platform and provided a solid foundation for this document.</p>

<p>The editor would also like to thank <span class="vcard">Alex Komoroske</span>, <span class="vcard">Angelina Fabbro</span>, <span class="vcard">Anne van Kesteren</span>, <span class="vcard">Boris Zbarsky</span>, <span class="vcard">Brian Kardell</span>, <span class="vcard">Daniel Buchner</span>, <span class="vcard">Edward O'Connor</span>, <span class="vcard">Eric Bidelman</span>, <span class="vcard">Erik Arvidsson</span>, <span class="vcard">Elliott Sprehn</span>, <span class="vcard">Hayato Ito</span>, <span class="vcard">James Simonsen</span>, <span class="vcard">Jonas Sicking</span>, <span class="vcard">Neel Goyal</span>, <span class="vcard">Olli Pettay</span>, <span class="vcard">Rafael Weinstein</span>, <span class="vcard">Scott Miles</span>, <span class="vcard">Steve Orvell</span>, <span class="vcard">Tab Atkins</span>, <span class="vcard">William Chan</span>, and <span class="vcard">William Chen</span> for their comments and contributions to this specification.</p>

<p>This list is too short. There's a lot of work left to do. Please contribute by reviewing and filing bugs—and don't forget to ask the editor to add your name into this section.</p>

</section>

</body></html>
